package dao.impl;

import dao.UserDao;
import pojo.User;

import java.sql.SQLException;

public class UserDaoImpl extends BaseDao implements UserDao {

    @Override
    public User queryByUsername(String uid) throws SQLException {
        String sql = "select * from user where uid=?";
        return queryForOne(User.class,sql,uid);
    }

    @Override
    public User queryByUsernameAndPassword(String uid, String password) throws SQLException {
        String sql = "select * from user where uid=? and password=?";
        return queryForOne(User.class,sql,uid,password);
    }

    @Override
    public int saveUser(User user) throws SQLException {
        String sql = "insert into user values(?,?,?)";
        return update(sql,user.getUid(),user.getNikename(),user.getPassword());
    }
}
